package com.example.its2021606134chh.TrafficViolationModule;

import android.content.Context;

import androidx.recyclerview.widget.LinearLayoutManager;

/**
 * @ClassName: CustomLinearLayoutManager$
 * @Description: 禁止条目滑动的工具类
 * @Author: letquit
 * @CreateDate: 10/8/2021$
 * @Version: 1.0
 */
public class CustomLinearLayoutManager extends LinearLayoutManager {
    private boolean isScrollEnabled = true;

    public CustomLinearLayoutManager(Context context) {
        super(context);
    }

    public void setScrollEnabled(boolean flag) {
        this.isScrollEnabled = flag;
    }

    /**
     * 禁止滑动
     * canScrollHorizontally（禁止横向滑动）
     * @return
     */
    @Override
    public boolean canScrollHorizontally() {
        return isScrollEnabled && super.canScrollVertically();
    }
    /**
     * 禁止滑动
     * canScrollVertically（禁止竖向滑动）
     * @return
     */
    @Override
    public boolean canScrollVertically() {
        return isScrollEnabled && super.canScrollVertically();
    }
}